﻿using Shop.RemoteModel.FrontCategory.Model;
using Shop.StoreGatewayModular.Interface;
using WeDonekRpc.ApiGateway.Attr;
using WeDonekRpc.Helper.Validate;
using WeDonekRpc.HttpApiGateway;
using WeDonekRpc.HttpApiGateway.Model;

namespace Shop.StoreGatewayModular.Api
{
    [ApiRouteName("/shop/front/category/{name}")]
    internal class FrontCategoryApi : ApiController
    {
        private readonly IFrontCategoryService _Service;

        public FrontCategoryApi (IFrontCategoryService service)
        {
            this._Service = service;
        }

        public long Add (FrontCategoryAdd add)
        {
            return this._Service.Add(add);
        }

        public void Delete ([NumValidate("shop.front.category.id.error", 1)] long id)
        {
            this._Service.Delete(id);
        }

        public void Disable ([NumValidate("shop.front.category.id.error", 1)] long id)
        {
            this._Service.Disable(id);
        }

        public void Enable ([NumValidate("shop.front.category.id.error", 1)] long id)
        {
            this._Service.Enable(id);
        }

        public FrontCategoryDatum Get ([NumValidate("shop.front.category.id.error", 1)] long id)
        {
            return this._Service.Get(id);
        }

        public FrontCategoryFullTree[] GetFullTree ()
        {
            return this._Service.GetFullTree();
        }

        public FrontCategoryTree[] GetTree (FrontCategoryGetParam param)
        {
            return this._Service.GetTree(param);
        }

        public void Move (LongNullParam<long?> param)
        {
            this._Service.Move(param.Id, param.Value);
        }

        public bool Set (LongParam<FrontCategorySet> param)
        {
            return this._Service.Set(param.Id, param.Value);
        }

        public bool SetBind (LongNullParam<long[]> param)
        {
            return this._Service.SetBind(param.Id, param.Value);
        }

        public Dictionary<long, int> SetSort (LongParam<int> param)
        {
            return this._Service.SetSort(param.Id, param.Value);
        }
    }
}
